ver=null

#src=read_write.cpp read.cpp
src=$(wildcard ./*.cpp)
#obj=read_write.o read.o
obj=$(patsubst ./%.cpp, ./%.o, $(src))
out=outpj_TCPserver

ifeq ($(ver), debug)
	CPPFLAGS = -D DEBUG -g -pthread -I json/ -I /home/blacksea3/vcpkg/installed/x64-linux/include/ -L/home/blacksea3/vcpkg/installed/x64-linux/debug/lib/ -ljsoncpp #-fsanitize=address -fno-omit-frame-pointer
else ifeq ($(ver), release)
	CPPFLAGS = -pthread -I json/ -I /home/blacksea3/vcpkg/installed/x64-linux/include/ -L/home/blacksea3/vcpkg/installed/x64-linux/debug/lib/ -ljsoncpp #-fsanitize=address -fno-omit-frame-pointer #-fsanitize=address -fno-omit-frame-pointer
else
	CPPFLAGS = 
endif

$(out):$(obj)
ifeq ($(ver), debug)
	@echo "in debug: generate .out"
	g++ -std=c++11 $(obj) -o $(out) -Wall $(CPPFLAGS)
else ifeq ($(ver), release)
	@echo "in release: don't generate .out"
else
	@echo "error: use make ver=debug or make ver=release"
	exit 1
endif

%.o:%.cpp
ifeq ($(ver), debug)
	g++ -std=c++11 -c $< -o $@ -Wall $(CPPFLAGS)
else ifeq ($(ver), release)
	FUCKYOU22222g++ -std=c++11 -c $< -o $@ -Walldsdssdd
else
	@echo "error: use make ver=debug or make ver=release"
	exit 1
endif

.PHONY:debugprint
debugprint:
	echo $(out)
	echo $(src)
	echo $(obj)

.PHONY:clean
clean:
	rm $(obj) $(out) -f

.PHONY:maketest
maketest:
	./$(out)
